import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/login',
        component: Login
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/admin',
        name: 'Admin',
        redirect: "/admin/control",
        component: () => import('../views/admin/Admin'),
        children:[
            {
                path: 'control',
                name: 'Control',
                component: () => import('../views/admin/Control'),
            },
            {
                path: 'user',
                name: 'User',
                component: () => import('../views/admin/User'),
            },
        ]
    },
    {
        path: '/404',
        name: '404',
        component: () => import('../views/404')
    },
    {
        path: '/:pathMatch(.*)',
        redirect: '/404'
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
